Online-Academy

Look, Read, Understand, Apply

Menu

Shapes and Colors

import java.awt.*;
import java.awt.event.*;

public class Colors extends Frame{
    public Colors(){
        addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent ww){
                System.exit(0);
            }
        });
    }
    public void paint(Graphics g){
        Color cc1 = new Color(255,100,100);
        Color cc2 = new Color(100,233,90);
        g.setColor(cc1);
        g.drawLine(20,80,100,80);
        g.drawLine(20,100,100,100);
        g.setColor(cc2);
        g.drawOval(20,40,50,50);
        g.fillOval(70,90,140,100);
        g.setColor(Color.blue);
        g.drawRoundRect(190,40,40,30,15,15);
    }
    public static void main(String[] aa){
        Colors app = new Colors();
        app.setSize(new Dimension(340,360));
        app.setTitle("Using Colors");
        app.setVisible(true);
    }
}